<?

if (!function_exists('basicMenuShow')) {
	function basicMenuShow($_menu, $levels, $current) {
		global $CURRENT;
//debug($GLOBALS['DATA']['crumb'], 'crumb');

		$_perm = stack('permitted', false);

		foreach($_menu as $id => $v) {
			
				if ($_perm) {
					$p = $CURRENT->parseUrl($v['value']);
					if (!permitted($_perm, $p['id'])) continue;
				}
			
			
			$class = array("level$current", $v['first'], $v['last']);
//debug($v['value']);
//debug(inCrumb($v['value']));
			if ($p = inCrumb($v['value'])) $class[] = "incrumb$current";
//debug($class);

			?><li class="<?=implode(' ', array_trim_empty($class))?>"><?
			
			if (($p && $p['last']) || !$v['value']) { 
				?><strong class="level<?=$current?>"><span><?=$v['name']?></span></strong><?
			} else { 
				?><a href="<?=$v['value']?>" title="<?=$v['text']?>" class="level<?=$current?>"><span><?=$v['name']?></span></a><? 
			} 
		
			if ($levels > $current) {
				
				if ($v['tag'] && isset($GLOBALS['DATA']['menus'][$v['tag']]) && sizeof($_m2 = $GLOBALS['DATA']['menus'][$v['tag']]['name'])) {

					if (is_array($_menu2 = $GLOBALS['DATA']['menu'][$_m2]) && sizeof($_menu2)) {
						
						?><ul class="level<?=$current + 1?>"><? basicMenuShow($_menu2, $levels, $current + 1); ?></ul><?
					}
				}
				
			}
	
			?></li><?
		}
		
	}
}

//debug($DATA['menu'], 'menu');
//debug($DATA['menus'], 'menus');

if (is_array($_menu = $DATA['menu'][stack('menu')]) && sizeof($_menu))
	basicMenuShow($_menu, stack('levels', 1), 1);

unstack();

